<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>
  
  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content">

    <div class="panel panel-default x-panel x-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/system">系统管理</a></li>
          <li class="active">基础数据</li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">

          <div class="x-breadcrumb-wrapper">
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>基础数据&nbsp;-&nbsp;门店列表</span></h2>
            </div>
          </div>
          
          <c:if test="${currentPrincipal.root or currentPrincipal.admin}">
            <div class="x-toolbar-wrapper clearfix" style="margin-top:20px;">
              <div class="btn-group pull-right">
                <a href="${ctx.host}/sites/create" data-target="#create-site" data-toggle="modal" title="添加门店" class="btn btn-default x-btn btn-shadow btn-shadow-default">
                  <i class="glyphicon glyphicon-plus"></i>&nbsp;&nbsp;添加门店
                </a>
              </div>
            </div>
          </c:if>
          
          <table class="table table-striped table-hover x-table bottom-margin-20" style="margin-bottom:20px;">
            <thead>
              <tr>
                <th>门店编号</th>
                <th>门店名称</th>
                <th>所属城市</th>
                <th>门店地址</th>
                <th>门店电话</th>
                <th>店长</th>
                <th>容量</th>
                <th class="text-center">操作</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach var="site" items="${sites}">
                <tr>
                  <td>${site.code}</td>
                  <td>${site.name}</td>
                  <td>${site.city}</td>
                  <td>${site.location.address}&nbsp;&nbsp;(${site.location.addressDescription})</td>
                  <td>${site.landline}</td>
                  <td>${site.manager == null ? '未指定' : site.manager.name}</td>
                  <td>
                    公共区域：${site.roomLimit.commonLimit}<br>
                    私有区域：${site.roomLimit.roomLimit}
                  </td>
                  <td class="text-center">
                    <a href="${ctx.host}/sites/${site.id}"  title="详情">详情</a>&nbsp;&nbsp;
                  </td>
                </tr>
              </c:forEach>
            </tbody>
          </table>
        </div>

      </div>
    </div>
  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/system/site/site-list.js">
    <script type="text/javascript">
      require(['page/system/site/site-list'] , function(page){
    	  page.init();
      })
    </script>
  </d:resource>
  
</body>

</html>